using UnityEngine;

public class RewardedAdsMarket : MonoBehaviour
{
	public RewardedAds rewardedAds;

	public AudioClip clip;

	public Color pressed;

	public Color unPressed;

	public GameObject visualButton;

	private void Update()
	{
		if (rewardedAds.IsPreloaded())
		{
			visualButton.SetActive(value: true);
			if (Input.GetMouseButtonUp(0))
			{
				ResetColors();
			}
			RaycastHit hitInfo;
			if (Input.GetMouseButtonDown(0) && Physics.Raycast(Camera.main.ScreenPointToRay(UnityEngine.Input.mousePosition), out hitInfo, 100f) && hitInfo.collider.name == "FreeExp")
			{
				visualButton.GetComponent<Renderer>().material.color = pressed;
				visualButton.GetComponent<Renderer>().material.SetColor("_SpecColor", pressed);
				rewardedAds.ShowAd();
			}
		}
		else
		{
			visualButton.SetActive(value: false);
		}
	}

	private void ResetColors()
	{
		visualButton.GetComponent<Renderer>().material.color = unPressed;
		visualButton.GetComponent<Renderer>().material.SetColor("_SpecColor", unPressed);
	}
}
